// ==UserScript==
// @name scrap on 280
// @author Spiky modded more
// @provided by http://www.orkut.com
// @description It sends scrap to all of ur friends at once!!
// @include *.orkut.com/Scrapz.aspx*
// ==/UserScript==



function fwScrap() {
document.title = "SCRAPS - SCRAPS PARA TODOS OS AMIGOS";

function createXMLHttpRequest() {
try {
return new XMLHttpRequest;
} catch (e) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Its navigating n \ xE3o possesss support \ xE0 technology AJAX!");
return false;
}
}
}
}


function getPostSig(exc) {
var xml = createXMLHttpRequest();
xml.open("GET", "/Scrapbook.aspx", true);
xml.onreadystatechange = function () {if (xml.readyState == 4) {var xmlr = xml.responseText;POST = xmlr.match(/name="post_token" value="([^"]+)/i);SIG = xmlr.match(/name="signature" value="([^"]+)/i);document.getElementsByTagName("input").POST_TOKEN.value = POST[1];document.getElementsByTagName("input").signature.value = SIG[1];eval(exc);}};
xml.send(null);
}


function loadFriends() {
var xml = createXMLHttpRequest();
xml.open("GET", "/Compose.aspx", true);
xml.onreadystatechange = function () {if (xml.readyState == 4) {var xmlr = xml.responseText;POST = xmlr.match(/name="post_token" value="([^"]+)/i);SIG = xmlr.match(/name="signature" value="([^"]+)/i);document.getElementsByTagName("input").POST_TOKEN.value = POST[1];document.getElementsByTagName("input").signature.value = SIG[1];var div = document.createElement("div");div.innerHTML = xmlr;for (var x = 0; x < div.getElementsByTagName("select").length; x++) {if (div.getElementsByTagName("select")[x].getAttribute("name") == "oneFriend") {var select = div.getElementsByTagName("select")[x].cloneNode(true);break;}}select.setAttribute("onchange", "document.getElementsByTagName('input')['oneFriendRadio'].checked=true");document.getElementById("friendSelector").innerHTML = "";document.getElementById("friendSelector").appendChild(select);document.getElementById("focus").style.display = "none";document.getElementById("divLoad").style.display = "none";}};
xml.send(null);
}


function wait() {
antiF = 1;
showTime();
}


function showTime() {
if (timeWait > 0) {
document.getElementById("status").innerHTML = "" + timeWait + " minute (s) to finish the Anti-Filter pause ";
timeWait--;
setTimeout("showTime()", 60000);
} else {
timeWait = 20;
index++;
getPostSig("sendScrap()");
}
}

antiF = 1;
index = 1;
timeWait = 20;

function sendScrap() {
if (document.getElementById("oneFriendRadio").checked &&
!document.getElementsByTagName("select").oneFriend.value) {
alert("choose the friend to whom the scrap should be sent");
return false;
}
if (!document.getElementById("body").value) {
alert("write scrap message");
return false;
}
if (index == document.getElementsByTagName("select").oneFriend.length) {
alert("Scrap sent");
return;
}
var name = "";
var primeiro = [];
var pattern = 0;
primeiro = document.getElementById("oneFriendRadio").checked ? document.getElementsByTagName("select").oneFriend[document.getElementsByTagName("select").oneFriend.selectedIndex].text.split(" ") : document.getElementsByTagName("select").oneFriend[index].text.split(" ");
name = primeiro[0];
pattern = name.match(/[a-zA-Z]+/);
y = 1;
while (!pattern && primeiro.length > y) {
pattern = primeiro[y].match(/[a-zA-Z]+/);
if (pattern) {
name = primeiro[y];
}
pattern = name.match(/[a-zA-Z]+/);
y++;
}
var scrapText = document.getElementById("body").value.replace(/%NAME%/g, name).replace(/\[(\/)?link\]/g, "") + "\n\n\n[purple]\n\n\n
[8)][b]Aprenda enviar Recados para todos amigos,[link=http://www.orkut.com/CommunityJoin.aspx?cmm=41998395]CLICK Aqui[/link][8)]
";



var send = document.getElementById("oneFriendRadio").checked ? "POST_TOKEN=" + encodeURIComponent(document.getElementsByTagName("input").POST_TOKEN.value) + "&signature=" + encodeURIComponent(document.getElementsByTagName("input").signature.value) + "&scrapText=" + encodeURIComponent(scrapText) + "&toUserId=" + document.getElementsByTagName("select").oneFriend.value + "&Action.submit=" : "POST_TOKEN=" + encodeURIComponent(document.getElementsByTagName("input").POST_TOKEN.value) + "&signature=" + encodeURIComponent(document.getElementsByTagName("input").signature.value) + "&scrapText=" + encodeURIComponent(scrapText) + "&toUserId=" + document.getElementsByTagName("select").oneFriend[index].value + "&Action.submit=";
var xml = createXMLHttpRequest();
xml.open("POST", "/Scrapbook.aspx", true);
xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
xml.send(send);
xml.onreadystatechange = function () {if (xml.readyState == 4) {if (xml.status != 200) {setTimeout("sendScrap()", 500);return;}document.getElementById("sendedScraps").innerHTML += sendedScrap(name, index % 2);document.getElementById("counterScraps").innerHTML = index;if (document.getElementById("oneFriendRadio").checked) {alert("Scrap sent");return;}if (antiF < 450) {antiF++;index++;setTimeout("sendScrap()", 1200);} else {wait();}}};
}


function sendedScrap(name, n) {
var span = n ? "" + name + "" : "" + name + "";
return span;
}


function insertName() {
txtarea = document.getElementById("body");
txtst = txtarea.scrollTop;
txtsl = txtarea.scrollLeft;
selLength = txtarea.textLength;
selStart = txtarea.selectionStart;
selEnd = txtarea.selectionEnd;
s1 = txtarea.value.substring(0, selStart);
s2 = txtarea.value.substring(selStart, selEnd);
s3 = txtarea.value.substring(selEnd, selLength);
txtarea.value = s1 + " %NAME% " + s2 + s3;
txtarea.selectionStart = selStart + 10;
txtarea.selectionEnd = selStart + 8 + s2.length;
txtarea.focus();
txtarea.scrollTop = txtst;
txtarea.scrollLeft = txtsl;
}

link = document.createElement("link");
link.href = "http://img3.orkut.com/img/i_scrap.gif";
link.rel = "SHORTCUT ICON";
link.type = "image/x-icon";
style = document.createElement("style");
style.textContent = "\n span.row1 {\n background-color: #BFD0EA;\n display: block;\n margin-left: 5px;\n }\n span.row0{\n background-color: #C9D6EB;\n display: block;\n margin-left: 5px;\n }\n\n #focus{\n position:fixed; \n width:100%; \n background:red; \n height: 100%; \n z-index: 1; \n left: 0; \n top: 0; \n opacity:.5; \n background-color: #000000;\n }\n #divLoad{\n position:fixed;\n background:#E5ECF4; \n z-index: 2; \n padding:5px; \n border:solid #BFD0EA 2px;\n left:40%; \n top:150px;\n }";
document.getElementsByTagName("head")[0].appendChild(style);
document.getElementsByTagName("head")[0].appendChild(link);
img_load = "http://img393.imageshack.us/img393/8894/orkutcarregando1zx5.gif";
layout = " Visit Site SCRAPS para TODOS os amigos!" + " " + " " + " " + " " + "
" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
" + " write scrap" + " " + " \" + " " + " " + "
" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
" + " choose:" + " " + " : " + "
" + " " + "
" + " message:" + " " + " " + " Text contains 0 characters (maximum 810 characters without tags HTML & DONOT SEND SAME SCRAP TO MORE THAN 280 FRIENDS AT THE SAME TIME)" + "
" + " \" + " " + " " + " " + " " + " " + "
" + " " + " " + " " + " " + " " + " " + "
" + " \" + " " + " Enviar scraps" + " " + " \" + "
" + "
" + " " + " " + " " + " " + " " + " " + "
" + " \" + " " + " insert name" + " " + " \" + "
" + "
" + "
" + "
" + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
" + " \ Mensagens enviadas: (0)" + "
" + " " + " " + " " + " " + "
" + " " + " " + " " + " " + "
" + "
" + " " + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
";
document.body.innerHTML = layout;
var focus = document.createElement("span");
focus.id = "focus";
focus.style.display = "inline";
document.body.appendChild(focus);
var divLoad = document.createElement("div");
divLoad.id = "divLoad";
divLoad.style.display = "inline";
divLoad.innerHTML = " " + "loading data...";
document.body.appendChild(divLoad);
loadFriends();
}

sc = String(fwScrap);
sc = sc.substring(21, sc.length - 2);
script = document.createElement("script");
if (typeof document.all) {
script.text = sc;
} else {
script.textContent = sc;
}
document.getElementsByTagName("head")[0].appendChild(script)